package Zoopark;

public class Zoo {

	private static final int MAX_ANIMALS = 10;
	private Animal[] animals = new Animal[MAX_ANIMALS];

	public void makeNoiseAllofYou() {
		for (Animal a : animals) {
			if (a != null && !(a instanceof Snake))
				a.makeNoise();
			else if (a != null) {
				((Snake) a).spitPoison();
			}
		}
	}

	public void addAnimal(Animal a) {
		if (a != null) {
			for (int animal = 0; animal < animals.length; animal++) {
				if (animals[animal] == null) {
					animals[animal] = a;
					return;
				}
			}
		}
	}

	public Animal getAnimal(int pos) {
		if (pos >= 0 && pos < MAX_ANIMALS)
			return animals[pos];
		return null;
	}

}
